package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.OrderManagementDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.service.OrderManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

@Service(interfaceClass = OrderManagementService.class)
@Transactional
public class OrderManagementServiceImpl implements OrderManagementService {
    @Autowired
    private OrderManagementDao orderManagementDao;

    //分页查询
    public PageResult findPage(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        Map<String, Object> queryMap = queryPageBean.getQueryMap();
        PageHelper.startPage(currentPage,pageSize);
        Page<Map<String, Object>> page = orderManagementDao.selectByCondition(queryMap);
        return new PageResult(page.getTotal(),page.getResult());
    }

}
